#include "PrecompiledHeaders.h"
#include "FirstPersonCamera.h"

/*
 * Sets up up to three camera based on the NULLness of the viewports. Positions
 * etc are set to simulate playing from inside the ball
 */
FirstPersonCamera::FirstPersonCamera(Ogre::Viewport *m_v, Ogre::Viewport *l_v,
    Ogre::Viewport *r_v, Ogre::SceneManager *sm) :
        ChaseCameraControl(m_v, l_v, r_v, sm, "fp_")
{
    position = Ogre::Vector3(0, 0, 0);
    l_offset = Ogre::Vector3::ZERO;
    Ogre::Vector3 look_at(0, 0, -20);
    Ogre::Radian yaw_angle(1.6);
    Ogre::Real clip_distance(0.52);
    main_camera->setPosition(position);
    main_camera->lookAt(look_at);
    main_camera->setNearClipDistance(clip_distance);
    main_camera->setFOVy(Ogre::Radian(acos(-1.0) * 0.5));
    if(l_v)
    {
        left_camera->setPosition(position + l_offset);
        left_camera->lookAt(look_at);
        left_camera->setNearClipDistance(clip_distance);
        left_camera->yaw(yaw_angle);
        left_camera->setFOVy(Ogre::Radian(acos(-1.0) * 0.5));
    }
    if(r_v)
    {
        right_camera->setPosition(position - l_offset);
        right_camera->lookAt(look_at);
        right_camera->setNearClipDistance(clip_distance);
        right_camera->yaw(-yaw_angle);
        right_camera->setFOVy(Ogre::Radian(acos(-1.0) * 0.5));
    }
}

void FirstPersonCamera::setBallSize(float size)
{
    Ogre::Real clip_distance(size * 0.52);
    main_camera->setNearClipDistance(clip_distance);
    // set other cameras
}
